package com.cqw.controller;

import com.cqw.common.BaseResponse;
import com.cqw.domain.LotteryRewardConfig;
import com.cqw.service.LotteryActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: caoqingwen
 * @CreateTime: 2021-04-28 11:30
 * @Description: 抽奖活动配置api
 */
@RestController
@RequestMapping("/activity/lottery")
@Slf4j
@Api(tags = "抽奖活动配置api")
public class LotteryActivityController {


    @Autowired
    private LotteryActivityService lotteryActivityService;


    @GetMapping("/reward/config")
    @ApiOperation(value = "查询奖项")
    public BaseResponse rewardConfigList(@RequestParam("activityId") Long activityId) {
        List<LotteryRewardConfig> list = lotteryActivityService.getRewardConfigList(activityId);
        return BaseResponse.success(list);
    }


    @GetMapping("/doLottery")
    @ApiOperation(value = "抽奖")
    public BaseResponse doLottery(@RequestParam("activityId") Long activityId) {
        LotteryRewardConfig lotteryRewardConfig = lotteryActivityService.doLottery(activityId);
        return BaseResponse.success(lotteryRewardConfig);
    }


}
